package com.awei.study.dataStructure.递归;

import java.util.Arrays;

public class bubble {

    public static void bubble(int a[], int j) {
        if(j == 0) {
//            System.out.println(Arrays.toString(Arrays.stream(a).toArray()));
            return;
        }
        int x = 0;
        for (int i = 0; i < j; i++) {
            if (a[i + 1] < a[i]) {
                int f = a[i];
                a[i] = a[i + 1];
                a[i + 1] = f;
                x = i;
            }
        }
        System.out.println(x);
        bubble(a, x);
    }

    public static void main(String[] args) {
        int a[] = new int[]{1,3,4,5,2};
        bubble(a,a.length - 1);
        System.out.println(Arrays.toString(Arrays.stream(a).toArray()));
    }
}
